< previous page page_804 next page >

Page 804
Table C.2 Records Returned Based on the Type of JOIN Used
JOIN Type TableRecords from Left TableRecords from Right Table
INNEROnly records with corresponding record in right tableOnly records with corresponding record in left table
LEFTAll recordsOnly records with corresponding record in left table
RIGHTOnly records with corresponding record in right tableAll reocords

To further understand these concepts, consider the sample database with its Customers and Salesperson tables. In that database, you created a small information set in the tables consisting of ten customers and four salespeople. Two of the customers have no salesperson listed, and one of the salespeople has no customers (he's a new guy!). You select the same fields with each JOIN but specify an INNER JOIN, LEFT JOIN, and RIGHT JOIN (see Listing C.7). Figure C.4 shows the two base-data tables from which this listing is working. Figure C.5 shows the resulting recordsets for each of the JOIN operations.
0804-01.jpg
Figure C.4
The Customers and Salesmen tables are RIGHT
JOINED to match salesmen to their customers.
Listing C.7 JOIN.TXTExamples of the Three JOIN Types
'**************************
'Select using an INNER JOIN
'**************************
SELECT CS.Lastname, CS.Firstname, SL.Saleslast, SL.Salesfirst  _
    FROM Customers AS CS, Salesmen AS SL,  _

 
< previous page page_804 next page >